<template>
  <div class="navbar">
    <el-menu
      :router="true"
      :default-active="$route.path"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#008842"
      text-color="#fff"
      active-text-color="#ffd04b"
    >
      <el-menu-item :index="item.path" v-for="item in munList" :key="item.path">
        <i :class="item.icon"></i>
        <span slot="title">{{ item.title }}</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 菜单列表
      munList: [
        {
          path: "/home/users",
          icon: "el-icon-user",
          title: "用户管理"
        },
        {
          path: "/home/goods",
          icon: "el-icon-goods",
          title: "商品管理"
        },
        {
          path: "/home/orders",
          icon: "el-icon-shopping-cart-full",
          title: "订单管理"
        }
      ]
    };
  },

  components: {},

  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  }
};
</script>

<style scoped>
</style>